package com.tshopping.dao;

import com.tshopping.bean.OrderDetails;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Repository
public interface OrderDetailsDao {

    @Insert("insert into order_details (orders,goods,number,parameter,time) values(#{orders},#{goods},#{number},#{parameter},#{time})")
    boolean insertOrderDetailsByAllData(OrderDetails orderDetails);

    @Select("select * from order_details where orders=#{orders}")
    ArrayList<OrderDetails> selectOderDetailsByOrderId(int order);

    @Select("select count(*) from order_details where orders=#{orders}")
    int selectCountByOrders(@Param("orders")int orders);

    @Select("select count(*) from order_details where orders=#{orders} and isCommented=0")
    int selectUnCommentedCount(@Param("orders")int orders);

    @Update("update order_details set isCommented=#{isCommented} where id=#{id}")
    boolean updateCommentById(@Param("isCommented")int isCommented,@Param("id") int id);

}
